﻿@using TavDom.Library.Entities.Concrete
@using TavDom.Library.UI.MVC.Helpers
@using TavDom.Library.UI.MVC.Models

@model ListViewModel<ContentType>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "Index";
}

<div class="row">
    <div class="col-lg-12 ">
        <ul class="breadcrumb form-top-menu">
            <li><i class="fa fa-home"></i>@Html.ActionLink("Anasayfa", "Index", "Home")</li>
            <li>@Html.ActionLink("Durum Yönetimi", "Index")</li>
            <li class="active">Durum Listele</li>
        </ul>
    </div>
</div>
<div class="content">
    <div class="main-header form-top-header">
        <h2>Listemele Alanı</h2>
    </div>
    <div class="main-content">

        @using (Html.BeginForm("Index", "ContentType", FormMethod.Post, new { @role = "form", @class = "FilterForm", id = "FilterForm" }))
        {
            <div class="widget">
                <div class="widget-header">
                    <h3><i class="fa fa-search"></i>Filtreleme Formu</h3>
                    <div class="btn-group widget-header-toolbar">

                        <a href="#" title="Göster" class="btn-borderless btn-toggle-expand"><i class="fa fa-chevron-up"></i></a>
                    </div>
                </div>
                <div class="widget-content">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="Name" class="control-label sr-only">Adı</label>
                                <input name="Name" class="form-control" type="text" placeholder="Adı" value="@ViewBag.Name">
                            </div>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-md-6">
                                        <label for="CreateDateBegin" class="control-label sr-only">Eklenme Tarihi Başlangıç</label>
                                        <input type="text" name="CreateDateBegin" placeholder="Eklenme Tarihi Başlangıç" class="form-control col-sm-12 datepicker" value="@ViewBag.CreateDateBegin">

                                    </div>
                                    <div class="col-md-6">
                                        <label for="CreateDateEnd" class="control-label sr-only">Eklenme Tarihi Bitiş</label>
                                        <input type="text" name="CreateDateEnd" placeholder="Eklenme Tarihi Bitiş" class="form-control col-sm-12 datepicker" value="@ViewBag.CreateDateEnd">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="row">
                                    <div class="col-md-6">
                                        <label for="UpdateDateBegin" class="control-label sr-only">Güncellenme Tarihi Başlangıç</label>
                                        <input type="text" name="UpdateDateBegin" placeholder="Güncellenme Tarihi Başlangıç" class="form-control col-sm-12 datepicker" value="@ViewBag.UpdateDateBegin">
                                    </div>
                                    <div class="col-md-6">
                                        <label for="UpdateDateEnd" class="control-label sr-only">Güncellenme Tarihi Bitiş</label>

                                        <input type="text" name="UpdateDateEnd" placeholder="Güncellenme Tarihi Bitiş" class="form-control col-sm-12 datepicker" value="@ViewBag.UpdateDateEnd">
                                    </div>
                                </div>
                            </div>
                            @Html.Hidden("page", (Object)ViewBag.page)
                            <div class="form-group">
                                <label for="IsApproved" class="control-label sr-only">Durum</label>
                                <select name="IsApproved" id="IsApproved" class="select-ticket-priority">

                                    @if (Model.Paging.IsSearch)
                                    {
                                        switch (Model.SearchEntities.IsApproved)
                                        {
                                            case 1:
                                                <option value="-1">[Tümü]</option>
                                                <option value="1" selected="selected">Onaylanmış</option>
                                                <option value="0">Onaylanmamış</option>
                                                break;
                                            case 0:
                                            <option value="-1">[Tümü]</option>
                                            <option value="1">Onaylanmış</option>
                                            <option value="0" selected="selected">Onaylanmamış</option>
                                                break;
                                            default:
                                            <option value="-1" selected="selected">[Tümü]</option>
                                            <option value="1">Onaylanmış</option>
                                            <option value="0">Onaylanmamış</option>
                                                break;
                                        }
                                    }
                                    else
                                    {
                                        <option value="-1" selected="selected">[Tümü]</option>
                                        <option value="1">Onaylanmış</option>
                                        <option value="0">Onaylanmamış</option>
                                    }
                                </select>

                            </div>

                            <div class="form-group">
                                <button type="submit" class="btn btn-primary" id="btnfilterpanel"><i class="fa fa-filter fa-fw"></i>Filtrele</button>
                            </div>
                        </div>
                        <hr class="inner-separator" />
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    @if (Model != null)
                    {
                        <div class="widget widget-table">
                            <div class="widget-header">
                                <h3><i class="fa fa-table"></i>Kayıtlar</h3>
                                <div class="btn-group widget-header-toolbar">

                                    <a href="#" title="Göster" class="btn-borderless btn-toggle-expand"><i class="fa fa-chevron-up"></i></a>

                                </div>
                                <div class="btn-group widget-header-toolbar">
                                    <a href="@Url.Action("Add")" class="label label-success"><i class="fa fa-plus-circle fa-fw"></i>Yeni Kayıt</a>
                                </div>

                            </div>
                            <div class="widget-content">
                                <table id="datatable-column-interactive" class="table table-sorting table-hover table-bordered datatable">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Adı</th>
                                            <th>Eklenme Tarihi</th>
                                            <th>Ekleyen</th>
                                            <th>Durum</th>
                                            <th>Düzenle</th>
                                            <th>Sil</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var m in Model.ListModelEntities)
                                        {
                                            <tr>
                                                <td class="text-right">
                                                    @m.Id
                                                </td>

                                                <td>
                                                    @m.Name
                                                </td>
                                                <td class="text-center">
                                                    @m.CreateDate.ToString("dd/MM/yyyy HH:mm:ss")
                                                </td>
                                                <td>
                                                    @m.CreatedBy.Name @m.CreatedBy.Surname
                                                </td>
                                                <td class="text-center">
                                                    @Html.DisplayFor(modelItem => m.IsApproved)
                                                </td>

                                                <td class="text-center">
                                                    <a href="@Url.Action("Update", new {id = m.Id})" class="btn btn-primary"><i class="fa fa-edit fa-fw"></i> Düzenle</a>
                                                </td>
                                                <td class="text-center">
                                                    <a href="@Url.Action("Delete", m)" class="btn btn-primary Delete" data-confirm-title="Emin misiniz?" data-confirm-message="Silmek istediğinizden emin misiniz?" data-confirm-ok="Evet" data-confirm-cancel="Hayır"><i class="fa fa-remove fa-fw"></i>Sil</a>
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                                <div class="row">
                                    <div class="col-lg-12">

                                        <ul class="pagination">
                                            <li class="previous"><a href="#">&laquo;</a></li>
                                            @{
                        Html.Pagination(Model.Paging.IsSearch, Model.Paging);
                                            }

                                            <li class="next"><a href="#">&raquo;</a></li>
                                        </ul>

                                    </div>
                                </div>

                            </div>
                        </div>
                    }
                </div>
            </div>
        }
    </div>
</div>
